# Delete Duplicate Email
Finds and removes duplicate email files (.msg and .eml) from document libraries by processing rows from an Excel file. Duplicates are identified by their Internet Message Id metadata field.
Filename pattern: filename must contain DeleteDuplicateEmail (case-insensitive).
Example: 20240115 DeleteDuplicateEmail cleanup.xlsx
# Columns
| Name | Required | Description |
|---|---|---|
| Url | Conditional | Server-relative URL of the document library. Required when MatterCode is not provided. |
| MatterCode | Conditional | Matter code used to resolve document libraries from the matter list. Required when Url is not provided. Processes all document libraries registered for the matter. |
| ClientCode | No | Client code used together with MatterCode to identify the matter. |
| RecycleBin / Recycle | No | Boolean. true sends duplicates to the recycle bin. false (default) permanently deletes them. |
| ModifyDate | No | If provided, only email files modified on or after this date are processed. Also guards against processing a library modified after this date (fails the row if the library was last modified after this date). |
Either Url or MatterCode must be provided.
# Behavior
The handler finds all .msg and .eml files in the target library. For each file, it reads the Internet Message Id (or Internetmessageid or Internet_x0020_message_x0020_id) metadata field. If a file's Internet Message Id has already been seen, it is treated as a duplicate and deleted or recycled. Files without an Internet Message Id are skipped. The oldest file (lowest ListItemID) is retained; later duplicates are removed.
# Related links
- Check-in Documents handler — manage checked-out files
- Update File Properties handler — update file metadata